const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const UserSchema = new Schema({
  userId: {
    type: Number,
    required: true,
    unique: true,
    comment: '用户ID'
  },
  deptId: {
    type: Number,
    comment: '部门ID'
  },
  userName: {
    type: String,
    required: true,
    comment: '用户账号'
  },
  nickName: {
    type: String,
    required: true,
    comment: '用户昵称'
  },
  email: {
    type: String,
    comment: '用户邮箱'
  },
  phoneNumber: {
    type: String,
    comment: '手机号码'
  },
  sex: {
    type: String,
    comment: '用户性别'
  },
  avatar: {
    type: String,
    comment: '用户头像'
  },
  password: {
    type: String,
    required: true,
    comment: '密码'
  },
  salt: {
    type: String,
    required: true,
    comment: '盐加密'
  },
  status: {
    type: String,
    default: '0',
    comment: '帐号状态（0正常 1停用）'
  },
  delFlag: {
    type: String,
    default: '0',
    comment: '删除标志（0代表存在 2代表删除）'
  },
  loginIp: {
    type: String,
    comment: '最后登录IP'
  },
  loginDate: {
    type: Date,
    comment: '最后登录时间'
  }
});

module.exports = mongoose.model('User', UserSchema);